<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/5/23
 * Time: 11:11
 */

namespace app\index\controller;


use app\admin\model\ShopMessage;

class News extends Base
{

    public function newsList(){
        return $this->fetch();
    }

    public function newsInfo($id){
        $data = ShopMessage::where('id',$id)->find();
        $this->assign('data',$data);
        return $this->fetch();
    }

    public function newsData(){
        $page = input('post.page');
        $limit = input('post.limit');
        $data = ShopMessage::order('pulishtime desc')->field('id,title,image')->page($page,$limit)->select()->toArray();
        $count = ShopMessage::count();
        if (!$data){
            return json(['code'=>0,'msg'=>'无数据','data'=>$data,'count'=>$count]);
        }
        return json(['code'=>1,'msg'=>'返回成功','data'=>$data,'count'=>$count]);
    }





}